<!DOCTYPE html>
<html>
<head>
   <title>CSS Animations - animation-timing-function in both keyframe and
   declaration</title>
   <link rel="author" title="Opera Software ASA" href="http://www.opera.com/">
   <link rel="help" href="http://dev.w3.org/csswg/css3-animations/#animation-timing-function_tag">
   <meta name="flags" content="dom">
   <meta name="assert" content="An 'animation-timing-function' defined within a
   keyframe block applies to that keyframe, otherwise the timing function
   specified for the animation is used">
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <style type="text/css">
      @keyframes move {
         0% {
            margin-left: 0px;
            animation-timing-function: linear;
         }
         50% {
            margin-left: 100px;
         }
         100% {
            margin-left: 200px;
         }
      }
      div {
         width: 100px;
         height: 100px;
         background: blue;
         animation-fill-mode: forwards;
         animation-duration: 1s;
         animation-timing-function: step-end;
      }
      .test {
         animation-name: move;
      }
   </style>
   <script type="text/javascript">
      setup({explicit_done:true});
      onload = function() {
         var testName = document.querySelector('title').firstChild.data;
         var div = document.querySelector('div');
         var log = document.querySelectorAll('p')[1].firstChild;
         var style = getComputedStyle(div, null);
         var passed = false;
         var timeout = setTimeout(function() {
            test(function(){assert_true(false);}, testName); done();
            log.data = 'FAIL';
         }, 1500);
         setTimeout(function() {
            var offsetPx = parseFloat(style.marginLeft);
            passed = (offsetPx > 0 && offsetPx < 100);
         }, 250);
         setTimeout(function() {
            passed = (passed && style.marginLeft == '100px');
         }, 750);
         div.addEventListener('animationend', function() {
            clearTimeout(timeout);
            passed = (passed && style.marginLeft == '200px');
            test(function(){assert_true(passed);}, testName); done();
            log.data = (passed ? 'PASS if the animation occurred.' : 'FAIL');
         });
         div.className = 'test';
      }
   </script>
   <style>iframe{display:none}</style>
</head>
<body>
   <p>The blue square below should move rightwards, sliding at constant speed
   the first half and then making an abrupt jump to the end.</p>
   <p>Testing...</p>
   <div></div>
</body>
</html>
